package com.example.switch_text.utils;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static ResponseResult genSuccessResult() {
        return new ResponseResult()
                .setResponseCode(ResultCode.SUCCESS)
                .setResponseMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static ResponseResult genSuccessResult(Object data) {
        return new ResponseResult()
                .setResponseCode(ResultCode.SUCCESS)
                .setResponseMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static ResponseResult genSuccessResult(Object data,String updateTime) {
        return new ResponseResult()
                .setResponseCode(ResultCode.SUCCESS)
                .setResponseMessage(DEFAULT_SUCCESS_MESSAGE)
                .setUpdateTime(updateTime)
                .setData(data);
    }

    public static ResponseResult genFailResult(String message) {
        return new ResponseResult()
                .setResponseCode(ResultCode.FAIL)
                .setResponseMessage(message);
    }

    public static ResponseResult genSuccessResult(String message) {
        return new ResponseResult()
                .setResponseCode(ResultCode.SUCCESS)
                .setResponseMessage(message);
    }

    public static ResponseResult gendDatabaseExceptionResult(String message) {
        return new ResponseResult()
                .setResponseCode(ResultCode.DATABASE_EXCEPTION)
                .setResponseMessage(message);
    }

    public static ResponseResult gendParamExceptionLackRequiredResult(String message) {
        return new ResponseResult()
                .setResponseCode(ResultCode.PARAM_EXCEPTION_LACK_REQUIRED)
                .setResponseMessage(message);
    }

    public static ResponseResult gendParamExceptionLllegalFormatResult(String message) {
        return new ResponseResult()
                .setResponseCode(ResultCode.PARAM_EXCEPTION_LLLEGAL_FORMAT)
                .setResponseMessage(message);
    }

    public static ResponseResult genFailResult(String code,String message) {
        return new ResponseResult()
                .setResponseCode(code)
                .setResponseMessage(message);
    }
}
